package com.brilliance.project.dao.impl;

import java.util.List;

import org.springframework.stereotype.Component;

import com.brilliance.project.dao.IAgentDao;
import com.brilliance.project.webapp.form.BaseForm;
import com.brilliance.project.webapp.form.sysmanage.AgentForm;

@Component("agentDaoImpl")
public class AgentDaoImpl extends BaseDaoImpl implements IAgentDao {

	@Override
	public List<BaseForm> queryByPg(AgentForm agentForm) {
		Integer totleCount = (Integer) this.getSqlSession().selectOne(
				"agent.countQuery", agentForm);
		setPageInfo(totleCount, agentForm);
		return this.getSqlSession().selectList("agent.queryByPg", agentForm);
	}

	@Override
	public List<BaseForm> query(AgentForm agentForm) {
		Integer totleCount = (Integer) this.getSqlSession().selectOne(
				"agent.countQuery", agentForm);
		setPageInfo(totleCount, agentForm);
		return this.getSqlSession().selectList("agent.query", agentForm);
	}

	@Override
	public boolean insert(AgentForm agentForm) {
		if (1 == this.getSqlSession().insert("agent.insert", agentForm)) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean delete(String agent_id) {
		if (this.getSqlSession().delete("agent.delete", agent_id) >= 1) {
			return true;
		} else {
			return false;
		}
	}

	@Override
	public boolean update(AgentForm agentForm) {
		if (this.getSqlSession().update("agent.update", agentForm) >= 1) {
			return true;
		} else {
			return false;
		}
	}

}
